package com.elvin.intents;

import java.io.File;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		findViewById(R.id.btnStartAty1).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
				//显示启动Activity方式一
				//Intent i = new Intent(MainActivity.this, Aty1.class);
				
				//显示启动Activity方式二
//				Intent i = new Intent();
//				i.setComponent(new ComponentName("com.elvin.intents", "com.elvin.intents.Aty1"));
				
				//隐式启动Activity，需要在配置文件添加内容
				Intent i = new Intent("com.elvin.intents.intent.action.Aty1");	
				startActivity(i);

			}
		});
		
		findViewById(R.id.btnOpenImage).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				File f = new File("/storage/sdcard1/DCIM/Camera/img2.jpg");
				Intent i = new Intent(Intent.ACTION_VIEW);
				i.setDataAndType(Uri.fromFile(f), "image/*");
				
				startActivity(i);
			}
		});
		
		findViewById(R.id.btnDel10010).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(Intent.ACTION_VIEW);
				i.setData(Uri.parse("tel:10010"));
				startActivity(i);

			}
		});
		
		findViewById(R.id.btnNav).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
				//i.setData(Uri.parse("http://www.baidu.com"));
				startActivity(i);

			}
		});
		
	}

}
